//
//  WHMoneyDetailInfoCell.m
//  SquirrelCourier
//
//  Created by 邓伟浩 on 2019/1/4.
//  Copyright © 2019 邓伟浩. All rights reserved.
//

#import "WHMoneyDetailInfoCell.h"

@interface WHMoneyDetailInfoCell ()

@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *statusLabel;

@end

@implementation WHMoneyDetailInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = CViewBgMainColor;
        [self setMoneyDetailInfoUI];
    }
    return self;
}

- (void)setMoneyDetailInfoUI {
    [self.contentView addSubview:({
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.textAlignment = NSTextAlignmentCenter;
        _dateLabel.adjustsFontSizeToFitWidth = YES;
        _dateLabel.textColor = CFontContentGrayColor;
        _dateLabel.font = SYSTEMFONT(kRealwidth(15));
        
        ViewBorderRadius(_dateLabel, 0, 0.5, CLineColor);
        
        _dateLabel;
    })];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.mas_equalTo(self.contentView);
        make.width.mas_equalTo(kRealwidth(115));
    }];
    
    [self.contentView addSubview:({
        _typeLabel = [[UILabel alloc] init];
        _typeLabel.textAlignment = NSTextAlignmentCenter;
        _typeLabel.adjustsFontSizeToFitWidth = YES;
        _typeLabel.textColor = CFontContentGrayColor;
        _typeLabel.font = SYSTEMFONT(kRealwidth(15));
        
        ViewBorderRadius(_typeLabel, 0, 0.5, CLineColor);
        
        _typeLabel;
    })];
    [_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self.contentView);
        make.left.mas_equalTo(_dateLabel.mas_right);
        make.width.mas_equalTo(kRealwidth(85));
    }];
    
    [self.contentView addSubview:({
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textAlignment = NSTextAlignmentCenter;
        _moneyLabel.adjustsFontSizeToFitWidth = YES;
        _moneyLabel.textColor = CFontContentGrayColor;
        _moneyLabel.font = SYSTEMFONT(kRealwidth(15));
        
        ViewBorderRadius(_moneyLabel, 0, 0.5, CLineColor);
        
        _moneyLabel;
    })];
    [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self.contentView);
        make.left.mas_equalTo(_typeLabel.mas_right);
        make.width.mas_equalTo(kRealwidth(85));
    }];
    
    [self.contentView addSubview:({
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.textAlignment = NSTextAlignmentCenter;
        _statusLabel.adjustsFontSizeToFitWidth = YES;
        _statusLabel.textColor = CFontContentGrayColor;
        _statusLabel.font = SYSTEMFONT(kRealwidth(15));
        
        ViewBorderRadius(_statusLabel, 0, 0.5, CLineColor);
        
        _statusLabel;
    })];
    [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self.contentView);
        make.left.mas_equalTo(_moneyLabel.mas_right);
        make.width.mas_equalTo(kRealwidth(90));
    }];
    
}

- (void)setMoneyModel:(WHDetailMoneyModel *)moneyModel {
    _moneyModel = moneyModel;
    
    _dateLabel.text = NSStringFormat(@"  %@  ", moneyModel.dealTime);
    
    switch (moneyModel.payType) {
        case 0:
            _typeLabel.text = @"充值";
            break;
        case 1:
            _typeLabel.text = @"支付";
            break;
        case 2:
            _typeLabel.text = @"提现";
            break;
            
        default:
            break;
    }
    _moneyLabel.text = moneyModel.totalAmount;
    
    switch (moneyModel.payStatus) {
        case 0:
            _statusLabel.text = @"失败";
            break;
        case 1:
            _statusLabel.text = @"成功";
            break;
        case 2:
            _statusLabel.text = @"提现中/退款中";
            break;
        case 3:
            _statusLabel.text = @"提现失败";
            break;
            
        default:
            break;
    }
    
}

@end
